package com.ruoyi.shuati.service.impl;

import java.util.List;

import cn.dev33.satoken.stp.StpUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.shuati.vo.userBank.UserBankListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shuati.mapper.ShuatiChapterMapper;
import com.ruoyi.shuati.domain.ShuatiChapter;
import com.ruoyi.shuati.service.IShuatiChapterService;

/**
 * 章节Service业务层处理
 *
 * @author ruoyi
 * @date 2024-06-17
 */
@Service
public class ShuatiChapterServiceImpl implements IShuatiChapterService
{
    @Autowired
    private ShuatiChapterMapper shuatiChapterMapper;

    /**
     * 查询章节
     *
     * @param id 章节主键
     * @return 章节
     */
    @Override
    public ShuatiChapter selectShuatiChapterById(Long id)
    {
        return shuatiChapterMapper.selectShuatiChapterById(id);
    }

    /**
     * 查询章节列表
     *
     * @param shuatiChapter 章节
     * @return 章节
     */
    @Override
    public List<ShuatiChapter> selectShuatiChapterList(ShuatiChapter shuatiChapter)
    {
        return shuatiChapterMapper.selectShuatiChapterList(shuatiChapter);
    }

    /**
     * 新增章节
     *
     * @param shuatiChapter 章节
     * @return 结果
     */
    @Override
    public int insertShuatiChapter(ShuatiChapter shuatiChapter)
    {
        System.out.println("获取到的loginId " + StpUtil.getLoginId());
        shuatiChapter.setUserId((String) StpUtil.getLoginId());
        shuatiChapter.setUpdateBy(StpUtil.getLoginId().toString());
        shuatiChapter.setCreateTime(DateUtils.getNowDate());
        return shuatiChapterMapper.insertShuatiChapter(shuatiChapter);
    }

    /**
     * 修改章节
     *
     * @param shuatiChapter 章节
     * @return 结果
     */
    @Override
    public int updateShuatiChapter(ShuatiChapter shuatiChapter)
    {
        shuatiChapter.setUpdateTime(DateUtils.getNowDate());
        return shuatiChapterMapper.updateShuatiChapter(shuatiChapter);
    }

    /**
     * 批量删除章节
     *
     * @param ids 需要删除的章节主键
     * @return 结果
     */
    @Override
    public int deleteShuatiChapterByIds(Long[] ids)
    {
        return shuatiChapterMapper.deleteShuatiChapterByIds(ids);
    }

    /**
     * 删除章节信息
     *
     * @param id 章节主键
     * @return 结果
     */
    @Override
    public int deleteShuatiChapterById(Long id)
    {
        return shuatiChapterMapper.deleteShuatiChapterById(id);
    }
}
